package com.fjrcloud.controller;

import com.fjrcloud.entity.*;
import com.fjrcloud.service.HousingDecorateService;
import com.fjrcloud.service.StorefrontStandardService;
import com.fjrcloud.service.HousingStructureService;
import com.fjrcloud.service.LandStandardService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * Created by shengjian.lin on 17-2-4.
 */
@Controller
@RequestMapping("housing")
public class HtmlHousingController {

    @Autowired
    private LandStandardService standardService;
    @Autowired
    private HousingStructureService housingStructureService;
    @Autowired
    private HousingDecorateService decorateService;
    @Autowired
    private StorefrontStandardService storefrontService;

    @RequestMapping("editor")
    public String editor(Model model){

        Page<LandStandard> standards = standardService.listBuilding(null,null);
        Page<HousingStructure> structures = housingStructureService.listStructure(null,null);
        Page<HousingStructureLevel> structureLevels = housingStructureService.listStructureLevelAll(null,null);
        Page<HousingStructureIntoNew> structureIntoNews = housingStructureService.listStructureIntoNew(null,null);
        Page<HousingDecorateLevel> decorateLevels = decorateService.listDecorateLevel(null,null);
        Page<HousingDecorateIntoNew> decorateIntoNews = decorateService.listDecorateIntoNew(null,null);


        model.addAttribute("standards",standards.getContent());
        model.addAttribute("structures",structures.getContent());
        model.addAttribute("structureLevels",structureLevels.getContent());
        model.addAttribute("structureIntoNews",structureIntoNews.getContent());
        model.addAttribute("decorateLevels",decorateLevels.getContent());
        model.addAttribute("decorateIntoNews",decorateIntoNews.getContent());

        return "housing-detail";
    }
    @RequestMapping("structure")
    public String structure(Model model){

        Page<HousingStructure> page = housingStructureService.listStructure(null,null);
        model.addAttribute("structures",page.getContent());

        return "housing-structure-level";
    }
    @RequestMapping("structure/intoNew")
    public String structureIntoNew(Model model){

        Page<HousingStructureIntoNew> page = housingStructureService.listStructureIntoNew(null,null);
        model.addAttribute("structureIntoNews",page.getContent());

        return "housing-structure-into-new";
    }
    @RequestMapping("decorate")
    public String decorate(Model model){

        Page<HousingDecorateLevel> decorateLevels = decorateService.listDecorateLevel(null,null);
        model.addAttribute("decorateLevels",decorateLevels.getContent());

        return "housing-decorate-level";
    }
    @RequestMapping("decorate/intoNew")
    public String decorateIntoNew(Model model){

        Page<HousingDecorateIntoNew> intoNews = decorateService.listDecorateIntoNew(null,null);
        model.addAttribute("intoNews",intoNews.getContent());

        return "housing-decorate-into-new";
    }
    @RequestMapping("storefront")
    public String storefront(Model model){

        Page<StorefrontStandard> storefronts = storefrontService.list(null,null);
        model.addAttribute("storefronts",storefronts.getContent());

        return "housing-storefront";
    }
}
